<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录_Gradual个人博客 - 一个在web后端为兴趣和生活努力的Java程序员个人博客网站</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/base.css" rel="stylesheet" th:href="@{/css/base.css}">
    <link href="css/index.css" rel="stylesheet" th:href="@{/css/index.css}">
    <link href="css/m.css" rel="stylesheet" th:href="@{/css/m.css}">
    <link rel="stylesheet" href="css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}">
    <link rel="stylesheet" href="css/login.css" th:href="@{/css/login.css}">
    <link rel="stylesheet" href="css/signin.css" th:href="@{/css/signin.css}">

</head>
<body>
<div th:replace="tmp/temp::#header"></div>

<form class="form-signin" id="userLogin" method="post" action="">
    <h1 class="h3 mb-3 font-weight-normal" style="margin-bottom: 20px;">请登录</h1>
    <!--判断-->
    <p style="color: red;"></p>
    <label class="sr-only">用户名</label>
    <input type="text" class="form-control" name="username" placeholder="Username" required="" autofocus="">
    <br>
    <label class="sr-only">密码</label>
    <input type="password" class="form-control" name="password" placeholder="Password" required="">
    <div class="checkbox mb-3">
        <label>
            <input type="checkbox" name="remember" value="remember-me"> 记住我
        </label>
    </div>
    <button class="btn btn-lg btn-default btn-block" id="login-btn" type="button">登录</button>
</form>
<script src="js/jquery.min.js" th:src="@{/js/jquery.min.js}" type="text/javascript"></script>
<script type="text/javascript" src="js/comm.js" th:src="@{/js/comm.js}"></script>
<script type="text/javascript" src="js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
<!--[if lt IE 9]>
<script src="js/modernizr.js" th:src="@{/js/modernizr.js}"></script>
    <![endif]-->

<script type="text/javascript">
    $(document).ready(function () {
        $('#login-btn').click(function () {
            $.ajax({
                type: 'post',
                url: '/login',
                data: $("#userLogin").serialize(),
                dataType: 'json',
                success: function (data) {
                    alert(data.message);
                    if (data.flag === true) {
                        window.location.href='/index.html';
                    }
                }
            })
        });
    });
</script>
</body>
</html>